package com.hmall.search.controller;

import com.hmall.common.client.ItemClient;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.PageDTO;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class itemController {

    @Autowired(required = false)
    private ItemService itemService;

    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key") String key){
        return itemService.suggestion(key);
    }

    @PostMapping("/filters")
    public Map<String,List<String>> filters(@RequestBody(required = false) RequestParams requestParams){
        return itemService.filters(requestParams);
    }

    @PostMapping("/list")
    public PageDTO<ItemDoc> list(@RequestBody RequestParams requestParams) {
        return itemService.list(requestParams);
    }
}
